home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / sources / environment.cp < prev    next >
Encoding:
Text File  |  2000-06-23  |  3.5 KB  |  129 lines

  1. /*
  2.     File:        Environment.cp
  3.  
  4.     Contains:    TEnvironment is a Gestalt wrapper class that finds out information about the environment.
  5.                   Environment.cp contains the member functions for the TEnvironment class.
  6.  
  7.     Written by: Kent Sandvik    
  8.  
  9.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. // INCLUDES
  25. #ifndef _ENVIRONMENT_
  26. #include "Environment.h"
  27. #endif
  28.  
  29.  
  30. // _________________________________________________________________________________________________________ //
  31. // TEnvironment class member function implementations
  32.  
  33. //    CONSTRUCTORS & DESTRUCTORS
  34. #pragma segment Environment
  35. TEnvironment::TEnvironment()
  36. {
  37.     // Set fields to known values.
  38.     fResult = false;
  39.     fLongResult = 0L;
  40. }
  41.  
  42. #pragma segment Environment
  43. TEnvironment::~TEnvironment()
  44. {
  45.  
  46. }
  47.  
  48.  
  49. //    MAIN INTERFACE
  50.  
  51. #pragma segment Environment
  52. Boolean TEnvironment::HasAttribute(OSType attribute,
  53.                                    short theBit)
  54. // Generic test that takes the Gestalt attribute and the bit value, and returns a Boolean.
  55. {
  56.     return (::Gestalt(attribute, &fLongResult) == noErr) && (((fLongResult >> theBit) & 1) != 0);
  57. }
  58.  
  59.  
  60. #pragma segment Environment
  61. Boolean TEnvironment::Check128k()
  62. // Checks if we are running under a 128k or better ROM.
  63. {
  64.     // check if 128k ROM Macintosh or not - the framework will not work properly
  65.     // on 64k ROM systems...
  66.  
  67.     SysEnvRec envRec;
  68.  
  69.     // ignore the error returned from SysEnvirons; even if an error occurred,
  70.     // the SysEnvirons glue will fill in the SysEnvRec
  71.     (void)::SysEnvirons(curSysEnvVers, &envRec);
  72.  
  73.     if (envRec.machineType < 0)                    // are we running on a 128K ROM machine or better???
  74.         return false;                            // we don't have a 128k System
  75.     else
  76.         return true;                            // we have a 128k System or better
  77. }
  78.  
  79.  
  80. #pragma segment Environment
  81. Boolean TEnvironment::HasAppleEvents()
  82. // Check if we have Apple Events support or not.
  83. {
  84.     fResult = (::Gestalt(gestaltAppleEventsAttr, &fLongResult) == noErr);
  85.     return fResult;
  86. }
  87.  
  88.  
  89. #pragma segment Environment
  90. Boolean TEnvironment::HasColorQD()
  91. // Check if we have Color QuickDraw support or not.
  92. {
  93.     fResult = (::Gestalt(gestaltQuickdrawFeatures, &fLongResult) == noErr);
  94.     return fResult;
  95. }
  96.  
  97.  
  98. #pragma segment Environment
  99. Boolean TEnvironment::IsSystemSeven()
  100. // Check if we are running on a System 7 version.
  101. {
  102.     ::Gestalt(gestaltSystemVersion, &fLongResult);// check for system version
  103.  
  104.     if (fLongResult >= 0x0700)
  105.         return true;
  106.     else
  107.         return false;
  108. }
  109.  
  110.  
  111. #pragma segment Environment
  112. Boolean TEnvironment::TrapAvailable(short aNumber,
  113.                                     TrapType aType)
  114. // Check if the trap is implemented or not.
  115. {
  116.     // Return true if trap is available
  117.     return (::NGetTrapAddress(aNumber, aType) != NGetTrapAddress(_Unimplemented,OSTrap));
  118. }
  119.  
  120.  
  121. // _________________________________________________________________________________________________________ //
  122.  
  123.  
  124. /*    Change History (most recent last):
  125.   No        Init.    Date        Comment
  126.   1            khs        11/9/92        New file
  127. */
  128.  
  129.